package method;

import node.Node;

public class displayNum {
    public static void work(Node head) {
        String ret= new String();
        Node cur=head.next;
        if(head.val==0) {
            ret=ret.concat("-");
        }
        if(head.next.val==0) {
            cur=cur.next;
        }
        while(cur!=null) {
            if(cur.prev==head) {
                ret = ret.concat(cur.val + "");
            } else {
                String tem = String.format("%04d", cur.val);
                ret = ret.concat(tem);
            }
            cur = cur.next;
        }
        //对开头一段多余的0处理
        int i=0;
        if(ret.charAt(0)=='-') {
            i=1;
        }
        while(ret.charAt(i)=='0') {
            i++;
        }
        if(ret.charAt(0)=='-') {
            ret = ret.substring(i, ret.length());
            ret = "-".concat(ret);
        } else {
            ret=ret.substring(i,ret.length());
        }
        System.out.println(ret);
    }
}
